#include "gtest/gtest.h"

#include "rocksdb/slice.h"

#include "helper/rocksdb/SliceUtil.h"


using SliceUtil = helper::rocksdb::SliceUtil;

TEST(SliceTest, testSaveInt64_t){
    int64_t n = 0x3453;
    rocksdb::Slice  s((const char*)&n, sizeof(n));

    ASSERT_EQ(n, *(int64_t*)s.data());
}


TEST(SliceHelperTest, testMain){
    {
        int64_t data = 0x3453ll;
        auto && s = SliceUtil::fromNumber<int64_t>(data);
        int64_t n = SliceUtil::toNumber<int64_t>(s);
        ASSERT_EQ(n, data);
    }
    {
        auto && s = SliceUtil::fromNumber<uint64_t>(0x3453);//also ok
        uint64_t n = SliceUtil::toNumber<uint64_t>(s);
        ASSERT_EQ(n, 0x3453ull);
    }
}
